package day17.reflection.factory;

/**
 * @author success
 * @version 1.0
 * @description:本类用来演示:
 * @date 2019/8/6 0006
 */
public class BeanFactory {

    public static IPointDao getInstance(String key){
        IPointDao pointDao = null;

        //反射的方式来创建对象
        //获取class实例 - 获取类的全限定名

        String className = PropUtils.getValue(key);

        try {
            Class<?> c = Class.forName(className);

            //反射创建对象
            pointDao = (IPointDao) c.newInstance();

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }

        return pointDao;
    }

}
